//
//  NSString+SubString.m
//  xiaohu
//
//  Created by 刘璇 on 2018/7/9.
//  Copyright © 2018年 iOSOneGpowerMobile. All rights reserved.
//

#import "NSString+SubString.h"

@implementation NSString (SubString)

+(void)load{
    
    Method OldMethod1 = class_getInstanceMethod(objc_getClass("NSString"), @selector(substringToIndex:));
    Method NewMethod1 = class_getInstanceMethod(objc_getClass("NSString"), @selector(nullString_substringToIndex:));
    
    method_exchangeImplementations(OldMethod1, NewMethod1);
    
}

-(NSString *)nullString_substringToIndex:(NSUInteger)to{
    
    if (self.length < to) {
        return [self nullString_substringToIndex:self.length];
    }
    
    return [self nullString_substringToIndex:to];
}






@end
